﻿using Playnite.SDK.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace HtmlDispatcher
{
    public static class GameExtensions
    {
        public static String GetPid(this Game game)
        {
            if (game.Notes is null) return "";
            Match match = Regex.Match(game.Notes, @"PID: (.*)[$|\r|\n]?", RegexOptions.IgnoreCase);
            if (match.Groups.Count > 0 && match.Groups[1].Success)
            {
                String keyword = match.Groups[1].Value;
                return keyword.Trim();
            }
            return "";
        }

        public static String GetInstallFolderName(this Game game)
        {
            if (game.Notes is null) return "";
            Match match = Regex.Match(game.Notes, @"InstallFolderName: (.*)[$|\r|\n]?", RegexOptions.IgnoreCase);
            if (match.Groups.Count > 0 && match.Groups[1].Success)
            {
                String keyword = match.Groups[1].Value;
                return keyword.Trim();
            }
            return "";
        }
    }
}
